/**
 * 
 */
package hottargui.config;

import hottargui.framework.Game;
import hottargui.framework.PlayerColor;
import hottargui.framework.WinnerStrategy;

/**
 * Combines 2 strategies where the secondary win condition will be executed if a
 * draw has occured in the primary win conditon
 */
public class DecisionWinnerStrategy implements WinnerStrategy {

	WinnerStrategy primaryWinCondition;
	WinnerStrategy secondaryWinCondition;

	DecisionWinnerStrategy(WinnerStrategy primaryWinConditionStrategy, WinnerStrategy secondaryWinConditionStrategy) {
		primaryWinCondition = primaryWinConditionStrategy;
		secondaryWinCondition = secondaryWinConditionStrategy;
	}

	public PlayerColor getWinner(Game game) {

		PlayerColor winColor = primaryWinCondition.getWinner(game);
		if (winColor != PlayerColor.None) {
			return winColor;
		} else {
			return secondaryWinCondition.getWinner(game);
		}
	}
}
